package com.eatme.web.security.authentication.converter;

import com.eatme.web.security.authentication.constant.IdentityType;

import javax.persistence.AttributeConverter;
import javax.persistence.Converter;

@Converter
public class IdentityTypeConverter implements AttributeConverter<IdentityType,Integer> {

    @Override
    public Integer convertToDatabaseColumn(IdentityType identityType) {
        return identityType.getCode();
    }

    @Override
    public IdentityType convertToEntityAttribute(Integer code) {
        return IdentityType.of(code);
    }
}
